require("../../assets/css/index.less");
require("./sportsPractice.less");
require("../../assets/fonts_two/iconfont");
const dom = require("../../utils/dom");
const axios = require("axios");
const https = require('../../utils/https');
const { footer, color, $, $$, addEvent } = require("../../utils/dom");
axios.defaults.headers.common['Authorization'] = "Bearer " + JSON.parse
dom.ready(function () {
    // 头部渲染
    dom.header('practice')
    // 页脚渲染
    footer('run');
    // 头部页面跳转
    dom.sportsHeadJump();
    // 获取课程训练列表
    https.get('/api/train/courseList', function (res) {
        console.log(res);
        if (res.errno == 0) {
            res.data.map(v => {
                console.log(v);
                if (v.courseId == 1) {
                    // 最新课程
                    $('.newcursor').innerHTML += `
                    <li>
                        <a href="sportsDetail.html?id=${v.courseId}">
                            <img src="${https.BASE_URL}${v.imgurl}" alt="图片损坏" height="150" width="100%">
                        </a>
                        <div class="content borbox pr">
                            <h5 id="newcursorTitle">${v.name}</h5>
                            <p id="newcursorDes" class="fon12">${v.desc}</p>
                        </div>
                    </li>
                    `
                } else {
                    // 课程列表
                    $('.cursorList').innerHTML += `
                    <li class="pr">
                        <a href="sportsDetail.html?id=${v.courseId}">
                            <img src="${https.BASE_URL}${v.imgurl}" alt="图片损坏" height="130" width="100%">
                        </a>
                        <div class="content borbox pa">
                            <h5 id="cursorListTitle">${v.name}</h5>
                            <p id="cursorListDes" class="fon12">${v.desc}</p>
                        </div>
                    </li>
                `
                }

            })
        }
    });

});

